<!DOCTYPE html>
<html>
  <head>
    <meta charset="utf-8">
    <title></title>
  </head>
  <body>
    <div id="wrap">
        <input type="text" name="username" id="username" value="">
        <input type="text" name="password" id="password" value="">
        <input type="submit" name="submit" id="submit" onclick="send()" value="注册">

    </div>
    <div class="wrap">
      <input type="text" name="username1" id="username1" value="">
      <input type="text" name="password1" id="password1" value="">
      <input type="submit" name="submit1" id="submit1" onclick="send_load()" value="登陆">
    </div>

  </body>
  <script type="text/javascript">
    //光标的移出事件
  document.getElementById('username').onblur =function(){


    if (window.XMLHttpRequest) {
        var request0 = new XMLHttpRequest();
    } else {
        var request0 = new ActiveXObject("Microsoft.XMLHTTP");
    }
  var url ="10.php?username="+document.getElementById('username').value;
    request0.open("GET",url,true);
    request0.send(null);
    request0.onreadystatechange = function() {

        if (request0.readyState == 4 && request0.status == 200) {

           alert(request0.responseText);
        
        };

    }
  }



  //注册发送请求
  function send(){
  if (window.XMLHttpRequest) {
      var request = new XMLHttpRequest();
  } else {
      var request = new ActiveXObject("Microsoft.XMLHTTP");
  }
var number =  createId();
console.log(number);
var myDate = new Date();
var mytime=myDate.toLocaleString();
console.log(mytime);
var url ="4.php?username="+document.getElementById('username').value+"&password="+document.getElementById('password').value+"&id="+number+"&time="+mytime;
  request.open("GET",url,true);
  request.send(null);
  request.onreadystatechange = function() {

      if (request.readyState == 4 && request.status == 200) {

         alert(request.responseText);

      };
      // 如果调用函数的时候，传入了成功的回调函数，我们调用这个函数
  }
};

function   createId(){
  var number = Math.floor(Math.random()*100000000001);
  return number;
}

//登陆发送请求
function send_load(){

if (window.XMLHttpRequest) {
    var request6 = new XMLHttpRequest();
} else {
    var request6 = new ActiveXObject("Microsoft.XMLHTTP");
}

var url ="5.php?username="+document.getElementById('username1').value+"&password="+document.getElementById('password1').value;

request6.open("GET",url,true);
request6.send(null);
request6.onreadystatechange = function() {

    if (request6.readyState == 4 && request6.status == 200) {
  console.log(request6.responseText);
      if (request6.responseText=="登陆成功") {

        window.location.href="http://localhost/php/1/5.html"
      }

    };
    // 如果调用函数的时候，传入了成功的回调函数，我们调用这个函数
}
};
  </script>
</html>
